DANVERS — The theme of the evening at Essex North Shore Agricultural and Technical School Friday evening was stepping out of life’s comfort zones.

Just ask Gov. Charlie Baker, who recounted his experience after losing his first run for governor.

“I wasn’t a good candidate,” Baker recalled realizing. “I was way outside my comfort zone and I lost.”

Afterward, he re-watched the debates, talked to the media, “listened to my friends go on and on, and on and on, about all the things I did wrong. At times it was exhausting and depressing.”

Then, one of his children told him, “Watching me lose made them less afraid to fail.”

“‘Dad, you gave it your best shot, you failed, and the next morning you got up and life went on.’” Baker quoted his son as telling him after that defeat in 2010.

“It’s OK to get outside of your comfort zone,” Baker told the graduates. “It’s OK if you fail, as long as you get back up and keep moving.”

“Your life is a team sport,” Baker told the 325 graduates. “Find your teammates, find your purpose and then, stretch yourself.”

Baker’s appearance at the graduation came just hours after he signed a $200 million infrastructure spending bill that could lead to jobs for some of the graduates.

Others will head on to college for further education.

“Today, you start as graduates of a terrific institution,” Baker, who stuck around to give each of the graduates a handshake as they received their diplomas, told them. “You have a strong foundation on which to build a positive and purposeful life.”

Salutatorian and fourth-generation Aggie graduate Virginia Vienneau of Groveland will head to Gordon College in the fall. In her speech, she urged her classmates to break the current trend of division and discrimination.

“I think we are all discovering kindness is hard,” said Vienneau, whose great grandfather was one of the first graduates of the school. “If we can learn to respect one another for the basic humanity we are all born with, it’s a good start.”

“Perhaps if everyone makes a little effort, respect will become the norm,” she said.

The school’s Vocational Student of the Year, Cameron Lampert, told his classmates that one of the most important things he learned during Army Reserve basic training last summer was about pushing himself.

“You have to learn how to be comfortable with being uncomfortable,” Lampert told the audience.

Valedictorian Azrielle Jiminez of Danvers has already experienced that change. When she started, she intended to focus on biotech and thought teeth were “disgusting.”

Now, she has training as a dental assistant and is headed to UMass Lowell this fall to pursue dentistry.

And all of her classmates, she said, made a choice to “step out of our comfort zone and into the unknown” when they left their home communities and local high schools, and the classmates they’d gone to school with for years, for Essex Tech.

Superintendent Heidi Riccio quoted Apple founder Steve Jobs, urging the graduates to take his advice to “follow your heart and your intuition” in life.

She also thanked the governor for his support of vocational and technical education.

“We are truly grateful to his commitment to building a future workforce and we are grateful for his presence this evening,” said Riccio.

School Committee chairman Mark Strout called the school “the finest agricultural and technical high school in the commonwealth of Massachusetts.”

Strout thanked Baker for his “staunch support of vocational and technical education.”

The ceremony was put together by the students in each of the school’s programs, from designing the programs to the sound.

Two graduating seniors, Jillian Miles and Lillian Phipps, sang the national anthem, taking turns with the verses.

Reporter Julie Manganis can be reached at 978-338-2521, by email at jmanganis@salemnews.com or on Twitter at @SNJulieManganis.